import type { Get } from '../client'
import type { SuccessData } from '../types'
import type { UserProfile } from '../user'

export type ClassModel = {
  id: number
  name: string
  courseID: number
  description: string
  teacher: UserProfile
  students: UserProfile[]
}

type ResClass = 'classes'
type ResStudent = 'students'

type GetClassData = SuccessData<ClassModel>

export type ClassStudentQueryKey = [Get, ResClass, number, ResStudent]
type GetClassStudentsData = SuccessData<UserProfile[]>

type PatchClassStudentsPayload = {
  op: 'add' | 'remove' | 'replace'
  value: string[]
}[]
type PatchClassStudentsData = SuccessData<UserProfile[]>

type SearchClassesPayload = {
  id?: number
  name?: string
  courseID?: number
  teacher?: string
  student?: string
}
export type SearchClassesQueryKey = [Get, ResClass, SearchClassesPayload]
type SearchClassesData = SuccessData<Omit<ClassModel, 'students'>[]>

type CreateClassPayload = Omit<ClassModel, 'students' | 'id' | 'teacher'> & { teacher: string }
type CreateClassData = SuccessData<Omit<ClassModel, 'students'>>

export type {
  GetClassStudentsData,
  PatchClassStudentsPayload,
  PatchClassStudentsData,
  CreateClassPayload,
  CreateClassData,
  GetClassData,
  SearchClassesPayload,
  SearchClassesData
}
